package com.umanji.board.service;

import java.util.List;

import com.umanji.board.domain.Notices;

import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
public interface NoticeService {

    @PostFilter("filterObject.email == principal.username or hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = true)
    List<Notices> findAll();

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = false)
    void persist(Notices entity);

    @PreFilter("filterObject.email == principal.username")
    @Transactional(value = "umanji", readOnly = false)
    void merge(Notices entity);

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = false)
    void remove(Notices entity);

    @Transactional(value = "umanji", readOnly = true)
    Notices find(Long id);
}
